#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>


int main()
{
	pid_t            pid = 0;
	int                *statu = NULL;

	pid_t            s;

	printf("Parent proccess PID[%d] star running...\n",getpid());

	pid = fork();

	if(pid<0)
	{
		printf("Fork failure: %s\n",strerror(errno));
		return -1;
	}
	else if(pid == 0)
	{
		printf("Child process PID [%d] star running,my parent PID[%d]\n",getpid(),getppid());
		//有可能会产生孤儿进程
		return 0;
	}

	else
	{
		sleep(1);//解决孤儿进程问题
	
		s=wait(statu);
		printf("Child process statu:%d\n",s);
		printf("Parent process PID[%d] continue running,and child process PID is [%d]\n",getpid(),pid);
		return 0;
	
	}

}
